<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%@taglib
	uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<sql:query dataSource="jdbc/sharewithme" var="ds">
	<%-- has isbnid shared ?? --%>
select count(*) as has from sharewithme.tbshare
where tbshare.isbn = '${param.bisbn }'
and tbshare.sharetypeid = 3
</sql:query>
<c:forEach items="${ds.rows }" var="has">
	<c:choose>
		<c:when test="${has.has != 0 }">

			<sql:query dataSource="jdbc/sharewithme" var="rs">
select ROUND (sum(tbshare.sharevalue)/topview.countrate ,1) as ratepoint ,
topview.countrate    
from sharewithme.tbshare tbshare, sharewithme.tbtopview topview
where tbshare.sharegroupid = 5
and tbshare.sharetypeid = 3
and tbshare.isbn = '${param.bisbn }'
and tbshare.isbn = topview.isbn
</sql:query>
			<c:forEach items="${rs.rows }" var="point">${point.ratepoint }</c:forEach>

		</c:when>
	</c:choose>
</c:forEach>
 <%-- ${sessionScope.User.userId } : ${param.bisbn }  --%>

<sql:query dataSource="jdbc/sharewithme" var="ds">
<%-- has userid , sharetypeid = 3 and isgn ?? --%>
select count(*) as has from sharewithme.tbshare
where tbshare.isbn = '${param.bisbn }'
and userid = '${sessionScope.User.userId }'
and sharetypeid = 3
</sql:query>
<c:forEach items="${ds.rows }" var="has">
	<c:choose>
		<c:when test="${has.has == 0 && sessionScope.User.userId != null}">
			: <select name="ratePoint">
				<c:forEach begin="1" end="5" step="1" var="rate">
					<option value="${rate }">${rate }</option>
				</c:forEach>
			</select>
			<input type="submit" value="Vote!" name="voteButton">
		</c:when>
	</c:choose>
</c:forEach>


